package com.leapp.sk.viewdelegate.leave

import android.content.Context
import android.support.v4.content.ContextCompat
import android.support.v4.widget.SwipeRefreshLayout
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.RefreshListView
import com.leapp.sk.R
import com.leapp.sk.bean.LevelEntity
import com.leapp.sk.bean.ParentingTaskEntity
import com.leapp.sk.ui.adapter.ParentingTaskAdapter
import com.leapp.sk.ui.adapter.TeacherLeaveAdapter

/**
 * 待审批视图托管类
 * @author  chaohaipeng  on 2018/8/13.
 */
class ApprovalPendingDelegate :BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.fragment_approval_pending
    }
    /**
     * 初始化适配器
     */
    fun initAdapter(context: Context, mlist: List<LevelEntity>, listener: SwipeRefreshLayout.OnRefreshListener, isApproval:Boolean){
        val lv_fap_leave_list = getView<RefreshListView>(R.id.lv_fap_leave_list)
        val srl_fap_leave_swipe = getView<SwipeRefreshLayout>(R.id.srl_fap_leave_swipe)
        val mAdapter = TeacherLeaveAdapter(getActivity(), mlist,isApproval)
        lv_fap_leave_list.adapter=mAdapter
        srl_fap_leave_swipe.setOnRefreshListener(listener)
        srl_fap_leave_swipe.setColorSchemeColors(ContextCompat.getColor(context, R.color.color_19AD19))
    }

    /**
     * 停止刷新
     */
    fun stopSwipRefresh(){
        val srl_fap_leave_swipe = getView<SwipeRefreshLayout>(R.id.srl_fap_leave_swipe)
        srl_fap_leave_swipe.isRefreshing=false
    }

}